<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>注册</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js" ></script>
</head>
<body>
<center>
	<form action="" method="post" >
		<table>
			<tr>
				<td>
					账号:<input type="text" id="uname" name="uName" onblur="check()" ><div id="error" ></div>
				</td>
			</tr>
			<tr>
				<td>
					公司名字:<input type="text" id="firmName" name="firmName" >
				</td>
			</tr>
			<tr>
				<td>
					公司税号:<input type="text" id="firmNum" name="firmNum" >
				</td>
			</tr>
			<tr>
				<td>
					密码:<input type="password" id="upwd" name="uPwd" >
				</td>
			</tr>
			<tr>
				<td>
					密码:<input type="password" id="upwd1" name="uPwd1" onblur="checkpwd()" ><div id="error1" ></div>
				</td>
			</tr>
			<tr>
				<td>
					<input type="button" id="sub" value="提交" onclick="subit()" >
				</td>
			</tr>
		</table>
	</form>
</center>

<script type="text/javascript">
	function check(){
		var name = $("#uname").val();
		
		$.ajax({
			type:"post",
			url:"../check",
			data:"name="+name,
			datatype:"json",
			success:function (msg){
					if(msg.sta == "1"){
						$("#error").html("可以注册!");
						}
					if(msg.sta == "0"){
						$("#error").html("用户存在!");
						}
				}
			});
		}
	function checkpwd(){
		var pwd = $("#upwd").val();
		var pwd1 = $("#upwd1").val();
		if(pwd == pwd1){
			$("#error1").html("密码一致");
			}else{
				$("#error1").html("密码不一致");
				}
	}
	function subit(){
		var name = $("#uname").val();
		var pwd = $("#upwd").val();
		var pwd1 = $("#upwd1").val();
		var firmName = $("#firmName").val();
		var firmNum = $("#firmNum").val();
		if(name !=null || pwd != null || firmName != null || firmNum != null){
				if(pwd == pwd1){
					$("form").submit();
				}
			}
		
		}
	
</script>

</body>
</html>